import React, { FC, useEffect, useState } from 'react';
import * as echarts from 'echarts';
interface IEChartsProps {
  
};
let dataAxis = ['绿茶叶','红茶叶' ,'珍珠', '椰果', '果糖', '白糖', '香蜜', '奶昔粉', '奥利奥', '奶粉', '姜母汁', '咖啡豆', '红豆', '仙草汁', '冰沙粉', '果汁', '布丁粉', '焦糖', '话梅', '奶茶杯', ];
// prettier-ignore
const option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
};
let data = [220, 182, 191, 234, 290, 330, 310, 123, 442, 321, 90, 149, 210, 122, 133, 334, 198, 123, 125, 420];
let yMax = 500;
let dataShadow = [];

for (let i = 0; i < data.length; i++) {
  dataShadow.push(yMax);
}
const ECharts:FC<IEChartsProps> = () => {
  useEffect(() => {
    var myBarChart = echarts.init(document.getElementById('barECharts') as HTMLDivElement);
    const option = {
        // title: {
        //     text: '特性示例：渐变色 阴影 点击缩放',
        //     subtext: 'Feature Sample: Gradient Color, Shadow, Click Zoom'
        //   },
          xAxis: {
            data: dataAxis,
            axisLabel: {
              inside: true,
              color: '#fff'
            },
            axisTick: {
              show: false
            },
            axisLine: {
              show: false
            },
            z: 10
          },
          yAxis: {
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            axisLabel: {
              color: '#999'
            }
          },
          dataZoom: [
            {
              type: 'inside'
            }
          ],
          series: [
            {
              type: 'bar',
              showBackground: true,
              itemStyle: {
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                  { offset: 0, color: '#83bff6' },
                  { offset: 0.5, color: '#188df0' },
                  { offset: 1, color: '#188df0' }
                ])
              },
              emphasis: {
                itemStyle: {
                  color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
                    { offset: 0, color: '#2378f7' },
                    { offset: 0.7, color: '#2378f7' },
                    { offset: 1, color: '#83bff6' }
                  ])
                }
              },
              data: data
            }
          ]
    }
    myBarChart.setOption(option)
  }, [])



  return (
    <>
          <h2>产品库存</h2>
          <div id="barECharts" style={{ width: '100%', height: 500, backgroundColor: '#efefef'}}></div>

    </>
  )
};

export default ECharts;